﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Xml.Serialization;

namespace Sinacor.Infra.Tools.ErrorLogCollector
{
    public class LogPackage
    {
        [XmlElement]
        public Package<ClientEnvironmentData> Client { get; set; }
        [XmlElement]
        public Package<ServerEnvironmentData> Server { get; set; }
    }

    [Serializable]
    [XmlInclude(typeof(EventLogData))]
    [XmlInclude(typeof(FileLogData))]
    [XmlInclude(typeof(DbLogData))]
    public class Package<TEnvironment>
        where TEnvironment : ClientEnvironmentData, new()
    {
        public Package()
        {
            this.Environment = new TEnvironment();
            this.Logs = new List<LogData>();
        }

        [XmlElement]
        public TEnvironment Environment { get; set; }

        [XmlArray]
        [XmlArrayItem("EventLogData", typeof(EventLogData))]
        [XmlArrayItem("FileLogData", typeof(FileLogData))]
        [XmlArrayItem("DbLogData", typeof(DbLogData))]
        public List<LogData> Logs { get; set; }
    }
}
